<?php
class MessageAction extends BaseAction{
	public function index(){
            $Message = D("Message");
            $msg = $Message->order("id desc")->select();
            import("@.ORG.Page");
            $count = $Message->count();
            $Page = new Page($count, 10);
            $show = $Page->show();
            $this->assign('pages', $show);
            $this->assign("message",$msg);
            $this->assign("title",'留言');
            $this->display("Public:message");
	}
	public function edit(){
		if(!$_GET['id']){
			$this->assign("jumpUrl","__URL__");
			$this->error("数据不存在！");
		}
		$message = D("Message")->getById($_GET['id']);
		$this->assign($message);

		$this->display("Public:message");
	}
	public function reply(){
		$data = $_POST;
		$data['postdate'] = strtotime($_POST['postdate']);
		$data['replydate'] = strtotime($_POST['replydate']);
		if(D("Message")->save($data)){
			$this->success("回复或修改成功！");
		}else{
			$this->error("留言无改变或回复失败！");
		}
	}
	public function batch(){
		$this->_batch();
	}
}
?>